package Lianxi.ATM;


import IoLianxi.FileUtil;
import Lianxi.Doudizhu.Util2;
import MySql.Sql;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

/**
 * ATM顶层容器
 */

public class Atm extends JFrame {

    private ArrayList<User> users = new ArrayList<>();
    private Image btnImg = Util2.Util.getImage("/img/ATMbj.jpg");
    private CardLayout cardLayout = new CardLayout(); //卡片

    private Longin longin = new Longin(this); //登陆
    private Mun mun = new Mun(this); //菜单
    private Save save = new Save(this);   //存
    private Get get = new Get(this);     //取
    private Check check = new Check(this); //查询
    private Transfer transfer = new Transfer(this); //转账
    private Modify modify = new Modify(this);
    private User loginUser;  //用户对象
    private AtmSql atmSql = new AtmSql();


    public User getLoginUser() {
        return loginUser;
    }

    public void setLoginUser(User loginUser) {
        this.loginUser = loginUser;
    }

    public Atm() {



        this.setContentPane(new JPanel() {  //背景重写
            @Override  //重写背景样式
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(btnImg, 0, 0, 800, 800, this);
            }
        });


        this.setLayout(cardLayout); //卡片布局
        this.add("登录", longin); //登陆
        this.add("菜单", mun);    //菜单
        this.add("存款", save); //存
        this.add("取款", get);  //取
        this.add("查询", check); //查
        this.add("转账", transfer); //转账
        this.add("修改密码", modify); //修改密码


        this.setSize(800, 800);


        //设置窗体的文字标题
        this.setTitle("ATM");
        //设置窗体居中
        this.setLocationRelativeTo(null);
        //设置窗口关闭时程序结束
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        //设置窗体可见
        this.setVisible(true);


    }





    //sql数据库
//    public void data() {
//        atmSql.insert(this);
//
//    }


    public static void main(String[] args) {
        new Atm();
    }

    public void switchPanel(String name) {
        cardLayout.show(this.getContentPane(), name);
    }

    public ArrayList<User> getUsers() {
        return users;
    }

    public void setUsers(ArrayList<User> users) {
        this.users = users;
    }

    public Check getCheck() {
        return check;
    }

    public void setCheck(Check check) {
        this.check = check;
    }

    public Longin getLongin() {
        return longin;
    }

    public void setLongin(Longin longin) {
        this.longin = longin;
    }
}
